﻿#include "net.h"

net::net(const QString&path,QGraphicsScene*scene):pixmapItem(path,scene)
{

}

void net::advance(int phase)
{
    if(!collidingItems().empty())//碰撞检测
    {
        QList<QGraphicsItem*>list=collidingItems();
        for(QList<QGraphicsItem*>::iterator itor=list.begin();itor!=list.end();++itor)
        {
            //delete *itor;
            fish*f=(fish*)(*itor);//可能存在撒出去的网相互碰撞的情况,但不影响
            f->setPos(-qrand()%300,qrand()%400+100);
        }
    }
    delete this;//把网销毁
}
